<%@ page import="java.util.List"%>
<%@ page import="com.hargasembako.core.entity.*"%>

<%
	List<Store> stores = (List<Store>)request.getAttribute("stores");
%>

<html>
	<head>
		<title>Harga Sembako - Cari Store</title>
		<link rel="stylesheet" type="text/css" href="/stylesheets/styles.css"/>
	</head>
	<body>
		<span class="title">Harga Sembako Project</span>
		<p/>
		<p>
			Before creating a new Opportunity, ensure that the Store does not already exist. You can also 
			<a href="store?action=storeCreate"/>create a new store</a>.
		</p>
		<p/>
		<form method="post" action="store">
			<input type="hidden" name="action" value="storeLookup"/>
			<span class="heading">Search by Store Name:</span>
			<p/>
			<input type="text" name="store" value="<%if(request.getParameter("store")!=null){out.println(request.getParameter("store"));}%>" style="width:300px"/>	
			&nbsp
			<input type="submit" value="Search"/>
			&nbsp
		</form>
		
		<p/>
		<% if (stores.size() > 0) { %>
			<span class="heading">
				<%= stores.size() %> stores matching your search criteria:
			</span>
			<p/>
			<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC" width="50%">
				<tr bgcolor="#407BA8">
					<td style="color: #ffffff; font-weight: bold;">Name</td>
					<td style="color: #ffffff; font-weight: bold;">City</td>
					<td style="color: #ffffff; font-weight: bold;">State</td>
					<td style="color: #ffffff; font-weight: bold;">Phone</td>
				</tr>
				<% for (int i = 0;i<stores.size();i++) { %>
					<% Store a = (Store)stores.get(i); %>
					<tr style="background:#ffffff" onMouseOver="this.style.background='#eeeeee';" 
						onMouseOut="this.style.background='#ffffff';">
						<td>
							<a href="store?action=storeDisplay&storeId=<%= a.getId() %>">
								<%=a.getName() %>
							</a>
						</td>
						<td><%= a.getCity() %></td>
						<td><%= a.getState() %></td>
						<td><%= a.getPhone() %></td>
					</tr>
				<% } %>
			</table>
		<% } else { %>
			<span class="heading">No matching stores found.</span>
		<% } %>
		<p/>
	</body>
</html>
